home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / 3DMAZE / INITMAZE.C < prev    next >
Text File  |  1991-02-16  |  2KB  |  91 lines

  1. /******************************************************
  2. *
  3. *    InitMaze.c  v. 1.0
  4. *    1991 By Mark Frohnmayer
  5. *
  6. *    NOTE - This header must appear at the beginning of all 3-D maze files!
  7. *
  8. *    If you have any comments or recommended modifications for this code,
  9. *    email me on America On-Line at "Mark Frohn" or snail mail me at:
  10. *
  11. *            Mark Frohnmayer
  12. *            2875 Baker Blvd
  13. *            Eugene, OR 97403 
  14. *
  15. *    If you use this code in any program, commercial or otherwise, give
  16. *    me credit in the about box.
  17. *
  18. *    THIS CODE MAY NOT BE SOLD OR DISTRIBUTED AT COST OR AS PART OF SOLD
  19. *    PACKAGE WITHOUT PRIOR WRITTEN CONSENT OF THE AUTHOR.
  20. *
  21. ******************************************************/
  22.  
  23. #include "MazeData.h"
  24.  
  25. int         grdBytes;
  26. Ptr         MazeImgAdd[7];
  27. Rect        MazeRect;
  28. BitMap        MazeImage[7];
  29. viewpoint     u;
  30. view         uview;
  31. Rect        viewRects[15];
  32. char maze[16][16] = {
  33. { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
  34. { 1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1 },
  35. { 1,0,1,0,1,1,0,0,0,0,0,1,0,1,0,1 },
  36. { 1,0,1,0,1,0,1,0,0,0,0,0,1,1,0,1 },
  37. { 1,0,1,0,1,0,0,1,0,0,0,0,0,1,0,1 },
  38. { 1,0,1,0,1,1,0,1,1,0,0,0,0,0,0,1 },
  39. { 1,0,1,0,0,0,0,1,1,1,0,0,0,0,0,1 },
  40. { 1,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1 },
  41. { 1,0,0,0,0,0,0,0,0,0,1,0,0,1,1,1 },
  42. { 1,1,0,1,1,1,0,1,1,0,1,1,0,0,0,1 },
  43. { 1,1,0,0,0,1,0,1,1,0,0,0,1,1,0,1 },
  44. { 1,1,1,0,0,1,0,1,1,0,1,0,0,0,0,1 },
  45. { 1,0,1,0,1,0,0,0,1,0,1,0,1,0,0,1 },
  46. { 1,0,1,0,1,0,0,0,1,0,1,0,1,0,0,1 },
  47. { 1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,1 },
  48. { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
  49. };
  50.  
  51. int rectVals[30] =
  52. { 0,20,20,79,79,139,139,198,198,216, 0,60,60,158,158,216, 0,33,33,184,
  53.     184,216, 33,59,59,79,139,159,159,184 };
  54.     
  55. DoRects()
  56. {
  57.     int i;
  58.     for( i = 0; i < 15; i++) {
  59.         SetRect(&(viewRects[i]), rectVals[i*2], 0, rectVals[i*2 + 1], 185);
  60.     } 
  61. }
  62.  
  63. InitMaze()
  64. {
  65.     int i;
  66.     PicHandle thePic;
  67.     grdBytes = 28;
  68.     DoRects();
  69.     SetRect(&MazeRect, 0, 0, 216, 185);
  70.     thePic = GetPicture(134);
  71.     DrawPicture(thePic, &MazeRect);
  72.     do{} while(!Button());
  73.     for(i=0;i<7;i++) {
  74.         if(i != 6) thePic = GetPicture(128+i);
  75.         MazeImgAdd[i] = NewPtr((long) (28 * 185));
  76.         if(!MazeImgAdd[i]) ExitToShell();
  77.         MazeImage[i].baseAddr = (QDPtr) MazeImgAdd[i];
  78.         MazeImage[i].rowBytes = grdBytes;
  79.         SetRect(&MazeImage[i].bounds, 0, 0, 224, 185);
  80.         if(i != 6) {
  81.             EraseRect(&MazeRect);
  82.             DrawPicture(thePic, &MazeRect);
  83.             CopyBits(&thePort->portBits, &MazeImage[i], &MazeRect, 
  84.                 &MazeRect, srcCopy, 0L);
  85.         }
  86.     }
  87.     u.x = 1;
  88.     u.y = 14;
  89.     u.facing = 0;
  90.     SetView();
  91. }